package com.meitu.community.util;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.lang.reflect.Method;

public class ServletUtils {

    public static void callServletMethod(String methodName, Class mainClass, HttpServletRequest request, HttpServletResponse response) {
        try {
            Method method = mainClass.getDeclaredMethod(methodName, HttpServletRequest.class, HttpServletResponse.class);
            method.setAccessible(true);
            method.invoke(mainClass.newInstance(), request, response);
        } catch (Exception e) {
            e.printStackTrace();
            new RuntimeException(e);
        }
    }

}
